package cn.kgc.tangcco;

import org.junit.Test;

/**
 * @author 李昊哲
 * @Description for循环
 * @date 2020/8/13 上午10:41
 */
public class Demo15 {
    @Test
    public void test01() {
        int num = 0;
        while (num < 10) {
            System.out.println(num++);
        }
    }

    @Test
    public void test02() {
        // for(循环变量初始值;条件表达式;循环变量变化)
        for (int num = 0; num < 10; num++) {
            System.out.println(num);
        }
    }


    @Test
    public void test03() {
        // for(循环变量初始值;条件表达式;循环变量变化)
        for (int num = 0; num < 10; num++) {
            if (num % 2 == 0) {
                System.out.println(num);
            }
        }
    }

    @Test
    public void test04() {
        // for(循环变量初始值;条件表达式;循环变量变化)
        for (int num = 0; num < 10; num++) {
            if (num % 2 == 1) {
                continue;
            }
            System.out.println(num);
        }
    }

    @Test
    public void test05() {
        // for(循环变量初始值;条件表达式;循环变量变化)
        for (int num = 0; num < 10; num++) {
            System.out.println(num);
            if (num % 2 == 1) {
                continue;
            }
        }
    }

    @Test
    public void test06() {
        int sum = 0;
        for (int num = 0; num < 10; num++) {
            sum += num;
        }
        System.out.println(sum);
    }

    @Test
    public void test07() {

        for (int num = 0; num < 9; num++) {
            System.out.println("*");
        }
    }

}
